package com.sl.hx.shop.ui.mine.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sl.hx.shop.R;
import com.sl.hx.shop.bean.ProductList;

import java.text.DecimalFormat;
import java.util.List;

public class HistoryAdapter extends BaseQuickAdapter<ProductList,BaseViewHolder> {

    public HistoryAdapter(@Nullable List<ProductList> data) {
        super(R.layout.item_history, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ProductList item) {
        //设置小数点后一位
        DecimalFormat dfs= new DecimalFormat("0.0");

        if (item!=null) {
            helper.setText(R.id.GoodsName, item.getTitle())
                    .setText(R.id.GoodsPrice, dfs.format(Double.valueOf(item.getZk_final_price())) )
                    .setText(R.id.tb_price, "淘宝价格￥" + dfs.format(Double.valueOf( item.getReserve_price())) )
                    .setText(R.id.volume, item.getVolume() + "人已付款");

            ImageView image = helper.getView(R.id.icon);
            Glide.with(mContext).load(item.getPict_url()).into(image);

        }
    }
}
